const { PARAMS_ERROR, SYSTEM_ERROR } = require("../../../utils/errorCode");
const db = require("../../../db");

exports.main = (req, res) => {
    // 获取数据
    const {
        productId
    } = req.body
    if (!productId || productId < 0) {
        return res.err(PARAMS_ERROR, "商品id错误")
    }
    let sql = `select *
               from products
               where isDelete = '0'
                 and productId = ?;`;

    db.query(sql, productId, (err, result) => {
        if (err) {
            console.log(err);
            return res.err(SYSTEM_ERROR);
        }

        return res.sd(result[0]);
    })
}